import { reqSearchInfo } from '@/api'
// search模块的小仓库
const state = {
     // 初始值
     searchInfo: {}
}
const mutations = {
     GETSEARCHINFO(state,searchInfo){
          state.searchInfo = searchInfo
     }
}
const actions = {
     // 获取search模块数据
     async getSearchInfo({ commit }, params = {}) {
          let res = await reqSearchInfo(params)
          // console.log(res)
          if(res.data.code === 200){
               commit('GETSEARCHINFO',res.data.data)
          }
     }
}
const getters = {
     // state  当前search的state
     goodsList(state) {
          return state.searchInfo.goodsList || [];
     },
     //品牌的数据
     trademarkList(state) {
          return state.searchInfo.trademarkList || [];
     },
     //商品属性
     attrsList(state) {
          return state.searchInfo.attrsList || [];
     }
}
export default {
     state,
     mutations,
     actions,
     getters
}